package com.hxd.mall.module.product.pictureviewer

import android.app.Activity
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import com.hxd.mall.R
import java.util.*

/**
 * @Describe 图片浏览
 * @Date : 2019/1/13
 * @Author : zhaoyong
 */
class PictureViewActivity : Activity() {

    private var mPicView: LargePictureView? = null
    private var mImages: List<String>? = null
    //private var mBottomDialog: BottomDialog? = null
    private var mIndex: Int = 0

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        mImages = intent.getStringArrayListExtra("images")
        mIndex = intent.getIntExtra("index", 0)
        setContentView(R.layout.activity_picture_view_layout)
        mPicView = findViewById(R.id.pic_scan)
        mPicView!!.setImages(mImages!!).show()
        mPicView!!.setLisenter(object : LargePictureView.OnClickeListener {
            override fun onClick(index: Int) {
                finish()
            }

            override fun onLongClick(v: View, index: Int) {
                //showBottomDialog((v as LargePictureView).getItem(index))
            }
        })
        mPicView!!.setPage(mIndex)
    }

    /*private fun showBottomDialog(url: String) {
        mBottomDialog = BottomDialog(this, R.layout.dialog_pic_scan_menu_layout)
        mBottomDialog!!.getView(R.id.dismiss, true)
        mBottomDialog!!.getView(R.id.save, true)

        mBottomDialog!!.setOnClickListener(View.OnClickListener { v ->
            if (v.id == R.id.dismiss) {
                mBottomDialog!!.dismiss()
            } else if (v.id == R.id.save) {
                DownloadUtils.startDownloadImage(this@PictureViewActivity, url)
            }
        })
        mBottomDialog!!.show()
    }*/

    companion object {

        fun launch(context: Context, images: List<String>, index: Int) {
            val intent = Intent(context, PictureViewActivity::class.java)
            intent.putStringArrayListExtra("images", images as ArrayList<String>)
            intent.putExtra("index", index)
            context.startActivity(intent)
        }
    }
}
